package com.swotxu.oldwebproject.session.listener.filter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.EventObject;

/**
 * @Date: 2021/3/25 0025 14:03
 * @Author: swotxu
 */
public class RedisFilterEvent extends EventObject {
    /**
     * Constructs a prototypical Event.
     *
     * @param request The object on which the Event initially occurred.
     * @param response The object on which the Event initially occurred.
     * @throws IllegalArgumentException if source is null.
     */
    public RedisFilterEvent(HttpServletRequest request, HttpServletResponse response) {
        super(new HttpServletHolder(request, response));
    }

    @Override
    public HttpServletHolder getSource() {
        return (HttpServletHolder) super.getSource();
    }

    public HttpServletRequest getRequest() {
        return getSource().request;
    }

    public void setRequest(HttpServletRequest request) {
        getSource().request = request;
    }

    public HttpServletResponse getResponse() {
        return getSource().response;
    }

    public void setResponse(HttpServletResponse response) {
        getSource().response = response;
    }

    static class HttpServletHolder {
        private HttpServletRequest request;
        private HttpServletResponse response;

        HttpServletHolder(HttpServletRequest request, HttpServletResponse response) {
            this.request = request;
            this.response = response;
        }
    }
}
